dependencies = [
"advapi32-sys 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"curl 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "docopt 0.6.47 (registry+https://github.com/rust-lang/crates.io-index)",
+ "docopt 0.6.51 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"flate2 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "git2 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "git2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"git2-curl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "glob 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "glob 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"hamcrest 0.1.0 (git+https://github.com/carllerche/hamcrest-rust.git)",
- "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "kernel32-sys 0.0.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
"registry 0.1.0",
- "rustc-serialize 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"semver 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
- "tar 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tar 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"tempdir 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "term 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
+ "term 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"threadpool 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "time 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
]
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"curl-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libz-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "docopt"
-version = "0.6.47"
+version = "0.6.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"log 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"miniz-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "git2"
-version = "0.2.1"
+version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libgit2-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libgit2-sys 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"curl 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "git2 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "git2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "url 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
+ "url 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "glob"
-version = "0.2.3"
+version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "hamcrest"
version = "0.1.0"
-source = "git+https://github.com/carllerche/hamcrest-rust.git#c90897390602ef1ad29de8988cc8b0ed23b540cd"
+source = "git+https://github.com/carllerche/hamcrest-rust.git#27a3368a915aabdee09c9f2c515127689715c1d9"
[[package]]
name = "kernel32-sys"
[[package]]
name = "libc"
-version = "0.1.2"
+version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libgit2-sys"
-version = "0.2.2"
+version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libssh2-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libssh2-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"libz-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "libssh2-sys"
-version = "0.1.11"
+version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libz-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libressl-pnacl-sys 2.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex"
-version = "0.1.19"
+version = "0.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
version = "0.1.0"
dependencies = [
"curl 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rustc-serialize"
-version = "0.3.1"
+version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
[[package]]
name = "tar"
-version = "0.2.3"
+version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
[[package]]
name = "term"
-version = "0.1.13"
+version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.0.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "time"
-version = "0.1.19"
+version = "0.1.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "rustc-serialize 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "url"
-version = "0.2.23"
+version = "0.2.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
docopt = "0.6.45"
url = "0.2.23"
rustc-serialize = "0.3.1"
-term = "0.1.13"
+term = "0.2"
regex = "0.1.18"
threadpool = "0.1.1"
libc = "0.1.2"
registry = { path = "src/registry" }
[target.i686-pc-windows-gnu]
-dependencies = { winapi = "0.1", advapi32-sys = "*" }
+dependencies = { winapi = "0.1", advapi32-sys = "*", kernel32-sys = "*" }
[target.x86_64-pc-windows-gnu]
-dependencies = { winapi = "0.1", advapi32-sys = "*" }
+dependencies = { winapi = "0.1", advapi32-sys = "*", kernel32-sys = "*" }
[dev-dependencies]
tempdir = "0.3"
-#![feature(core, io, path, std_misc, exit_status)]
+#![feature(core, io, std_misc, exit_status)]
extern crate "git2-curl" as git2_curl;
extern crate "rustc-serialize" as rustc_serialize;
let mut contents = String::new();
let file = File::open(&args.flag_manifest_path);
match file.and_then(|mut f| f.read_to_string(&mut contents)) {
- Ok(()) => {},
+ Ok(_) => {},
Err(e) => return fail("invalid", &format!("error reading file: {}", e))
};
match toml::Parser::new(&contents).parse() {
use std::fmt;
-use std::old_io::{IoResult, stderr};
+use std::io::prelude::*;
+use std::io;
use term::Attr;
use term::color::{Color, BLACK, RED, GREEN, YELLOW};
}
enum AdequateTerminal {
- NoColor(Box<Writer + Send>),
+ NoColor(Box<Write + Send>),
Colored(Box<Terminal<UghWhyIsThisNecessary> + Send>)
}
}
struct UghWhyIsThisNecessary {
- inner: Box<Writer + Send>,
+ inner: Box<Write + Send>,
}
impl MultiShell {
&mut self.err
}
- pub fn say<T: ToString>(&mut self, message: T, color: Color) -> IoResult<()> {
+ pub fn say<T: ToString>(&mut self, message: T, color: Color) -> io::Result<()> {
self.out().say(message, color)
}
- pub fn status<T, U>(&mut self, status: T, message: U) -> IoResult<()>
+ pub fn status<T, U>(&mut self, status: T, message: U) -> io::Result<()>
where T: fmt::Display, U: fmt::Display
{
self.out().say_status(status, message, GREEN)
}
- pub fn verbose<F>(&mut self, mut callback: F) -> IoResult<()>
- where F: FnMut(&mut MultiShell) -> IoResult<()>
+ pub fn verbose<F>(&mut self, mut callback: F) -> io::Result<()>
+ where F: FnMut(&mut MultiShell) -> io::Result<()>
{
if self.verbose { return callback(self) }
Ok(())
}
- pub fn concise<F>(&mut self, mut callback: F) -> IoResult<()>
- where F: FnMut(&mut MultiShell) -> IoResult<()>
+ pub fn concise<F>(&mut self, mut callback: F) -> io::Result<()>
+ where F: FnMut(&mut MultiShell) -> io::Result<()>
{
if !self.verbose { return callback(self) }
Ok(())
}
- pub fn error<T: ToString>(&mut self, message: T) -> IoResult<()> {
+ pub fn error<T: ToString>(&mut self, message: T) -> io::Result<()> {
self.err().say(message, RED)
}
- pub fn warn<T: ToString>(&mut self, message: T) -> IoResult<()> {
+ pub fn warn<T: ToString>(&mut self, message: T) -> io::Result<()> {
self.err().say(message, YELLOW)
}
}
impl Shell {
- pub fn create(out: Box<Writer + Send>, config: ShellConfig) -> Shell {
+ pub fn create(out: Box<Write + Send>, config: ShellConfig) -> Shell {
let out = UghWhyIsThisNecessary { inner: out };
if config.tty && config.color {
let term = TerminfoTerminal::new(out);
terminal: Colored(Box::new(t)),
config: config
}).unwrap_or_else(|| {
- Shell { terminal: NoColor(Box::new(stderr())), config: config }
+ Shell { terminal: NoColor(Box::new(io::stderr())), config: config }
})
} else {
Shell { terminal: NoColor(out.inner), config: config }
}
}
- pub fn verbose<F>(&mut self, mut callback: F) -> IoResult<()>
- where F: FnMut(&mut Shell) -> IoResult<()>
+ pub fn verbose<F>(&mut self, mut callback: F) -> io::Result<()>
+ where F: FnMut(&mut Shell) -> io::Result<()>
{
if self.config.verbose { return callback(self) }
Ok(())
}
- pub fn concise<F>(&mut self, mut callback: F) -> IoResult<()>
- where F: FnMut(&mut Shell) -> IoResult<()>
+ pub fn concise<F>(&mut self, mut callback: F) -> io::Result<()>
+ where F: FnMut(&mut Shell) -> io::Result<()>
{
if !self.config.verbose { return callback(self) }
Ok(())
}
- pub fn say<T: ToString>(&mut self, message: T, color: Color) -> IoResult<()> {
+ pub fn say<T: ToString>(&mut self, message: T, color: Color) -> io::Result<()> {
try!(self.reset());
if color != BLACK { try!(self.fg(color)); }
- try!(self.write_line(&message.to_string()));
+ try!(write!(self, "{}\n", message.to_string()));
try!(self.reset());
try!(self.flush());
Ok(())
}
pub fn say_status<T, U>(&mut self, status: T, message: U, color: Color)
- -> IoResult<()>
+ -> io::Result<()>
where T: fmt::Display, U: fmt::Display
{
try!(self.reset());
if color != BLACK { try!(self.fg(color)); }
if self.supports_attr(Attr::Bold) { try!(self.attr(Attr::Bold)); }
- try!(self.write_str(&format!("{:>12}", status)));
+ try!(write!(self, "{:>12}", status.to_string()));
try!(self.reset());
- try!(self.write_line(&format!(" {}", message)));
+ try!(write!(self, " {}\n", message));
try!(self.flush());
Ok(())
}
- fn fg(&mut self, color: color::Color) -> IoResult<bool> {
+ fn fg(&mut self, color: color::Color) -> io::Result<bool> {
match self.terminal {
Colored(ref mut c) => c.fg(color),
NoColor(_) => Ok(false)
}
}
- fn attr(&mut self, attr: Attr) -> IoResult<bool> {
+ fn attr(&mut self, attr: Attr) -> io::Result<bool> {
match self.terminal {
Colored(ref mut c) => c.attr(attr),
NoColor(_) => Ok(false)
}
}
- fn reset(&mut self) -> IoResult<()> {
+ fn reset(&mut self) -> io::Result<()> {
match self.terminal {
Colored(ref mut c) => c.reset().map(|_| ()),
NoColor(_) => Ok(())
}
}
-impl Writer for Shell {
- fn write_all(&mut self, buf: &[u8]) -> IoResult<()> {
+impl Write for Shell {
+ fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
match self.terminal {
- Colored(ref mut c) => c.write_all(buf),
- NoColor(ref mut n) => n.write_all(buf)
+ Colored(ref mut c) => c.write(buf),
+ NoColor(ref mut n) => n.write(buf)
}
}
- fn flush(&mut self) -> IoResult<()> {
+ fn flush(&mut self) -> io::Result<()> {
match self.terminal {
Colored(ref mut c) => c.flush(),
NoColor(ref mut n) => n.flush()
}
}
-impl Writer for UghWhyIsThisNecessary {
- fn write_all(&mut self, bytes: &[u8]) -> IoResult<()> {
- self.inner.write_all(bytes)
+impl Write for UghWhyIsThisNecessary {
+ fn write(&mut self, bytes: &[u8]) -> io::Result<usize> {
+ self.inner.write(bytes)
+ }
+ fn flush(&mut self) -> io::Result<()> {
+ self.inner.flush()
}
}
use std::fmt::{self, Formatter};
use std::hash;
use std::mem;
-use std::path::{Path, PathBuf};
+use std::path::Path;
use std::sync::Arc;
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
match self.inner.kind {
Kind::Git(..) => Box::new(GitSource::new(self, config)) as Box<Source>,
Kind::Path => {
- let path = match self.inner.url.to_file_path::<PathBuf>() {
+ let path = match self.inner.url.to_file_path() {
Ok(p) => p,
Err(()) => panic!("path sources cannot be remote"),
};
#![deny(unused)]
-#![feature(hash, os, std_misc, core)]
-#![feature(io, path, str_words, old_io, exit_status, fs_time)]
+#![feature(hash, os, std_misc, core, path_relative_from)]
+#![feature(io, str_words, exit_status, fs_time)]
#![cfg_attr(test, deny(warnings))]
#[cfg(test)] extern crate hamcrest;
use std::env;
use std::error::Error;
-use std::old_io::stdio::{stdout_raw, stderr_raw};
-use std::old_io::{self, stdout, stderr};
+use std::io::prelude::*;
+use std::io;
use rustc_serialize::{Decodable, Encodable};
use rustc_serialize::json::{self, Json};
use docopt::Docopt;
}
pub fn shell(verbose: bool) -> MultiShell {
- let tty = stderr_raw().isatty();
- let stderr = Box::new(stderr()) as Box<Writer + Send>;
+ let tty = isatty(libc::STDERR_FILENO);
+ let stderr = Box::new(io::stderr());
let config = ShellConfig { color: true, verbose: verbose, tty: tty };
let err = Shell::create(stderr, config);
- let tty = stdout_raw().isatty();
- let stdout = Box::new(stdout()) as Box<Writer + Send>;
+ let tty = isatty(libc::STDOUT_FILENO);
+ let stdout = Box::new(io::stdout());
let config = ShellConfig { color: true, verbose: verbose, tty: tty };
let out = Shell::create(stdout, config);
- MultiShell::new(out, err, verbose)
-}
+ return MultiShell::new(out, err, verbose);
+ #[cfg(unix)]
+ fn isatty(fd: libc::c_int) -> bool {
+ unsafe { libc::isatty(fd) != 0 }
+ }
+ #[cfg(windows)]
+ fn isatty(fd: libc::c_int) -> bool {
+ extern crate "kernel32-sys" as kernel32;
+ extern crate winapi;
+ unsafe {
+ let handle = kernel32::GetStdHandle(if fd == libc::STDOUT_FILENO {
+ winapi::winbase::STD_OUTPUT_HANDLE
+ } else {
+ winapi::winbase::STD_ERROR_HANDLE
+ });
+ let mut out = 0;
+ kernel32::GetConsoleMode(handle, &mut out) != 0
+ }
+ }
+}
// `output` print variant error strings to either stderr or stdout.
// For fatal errors, print to stderr;
}
fn json_from_stdin<T: Decodable>() -> CliResult<T> {
- let mut reader = old_io::stdin();
- let input = try!(reader.read_to_string().map_err(|_| {
+ let mut reader = io::stdin();
+ let mut input = String::new();
+ try!(reader.read_to_string(&mut input).map_err(|_| {
CliError::new("Standard in did not exist or was not UTF-8", 1)
}));
use std::collections::HashMap;
use std::default::Default;
use std::num::ToPrimitive;
-use std::os;
use std::path::{Path, PathBuf};
use std::sync::Arc;
}
None => None,
};
- let jobs = jobs.or(cfg_jobs).unwrap_or(os::num_cpus() as u32);
+ #[allow(deprecated)]
+ fn num_cpus() -> u32 { ::std::os::num_cpus() as u32 }
+ let jobs = jobs.or(cfg_jobs).unwrap_or(num_cpus());
let mut base = ops::BuildConfig {
jobs: jobs,
requested_target: target.clone(),
fn discover_author() -> CargoResult<(String, Option<String>)> {
let git_config = GitConfig::open_default().ok();
let git_config = git_config.as_ref();
- let name = git_config.and_then(|g| g.get_str("user.name").ok())
+ let name = git_config.and_then(|g| g.get_string("user.name").ok())
.map(|s| s.to_string())
.or_else(|| env::var("USER").ok()) // unix
.or_else(|| env::var("USERNAME").ok()); // windows
user, please set ${}", username_var)))
}
};
- let email = git_config.and_then(|g| g.get_str("user.email").ok());
+ let email = git_config.and_then(|g| g.get_string("user.email").ok());
let name = name.trim().to_string();
let email = email.map(|s| s.trim().to_string());
use std::fmt;
use std::path::{Path, PathBuf};
use std::fs;
-use std::io::prelude::*;
use rustc_serialize::{Encodable, Encoder};
use url::Url;
fn reset(&self) -> CargoResult<()> {
info!("reset {} to {}", self.repo.path().display(), self.revision);
let object = try!(self.repo.find_object(self.revision.0, None));
- try!(self.repo.reset(&object, git2::ResetType::Hard, None, None, None));
+ try!(self.repo.reset(&object, git2::ResetType::Hard, None));
Ok(())
}
}));
let obj = try!(repo.find_object(head, None));
- try!(repo.reset(&obj, git2::ResetType::Hard, None, None, None));
+ try!(repo.reset(&obj, git2::ResetType::Hard, None));
try!(update_submodules(&repo));
}
Ok(())
cred_helper.config(cfg);
let mut cred_error = false;
let ret = f(&mut |url, username, allowed| {
- let creds = if allowed.contains(git2::SSH_KEY) {
+ let creds = if allowed.contains(git2::SSH_KEY) ||
+ allowed.contains(git2::USERNAME) {
let user = username.map(|s| s.to_string())
.or_else(|| cred_helper.username.clone())
.unwrap_or("git".to_string());
- git2::Cred::ssh_key_from_agent(&user)
+ if allowed.contains(git2::USERNAME) {
+ git2::Cred::username(&user)
+ } else {
+ git2::Cred::ssh_key_from_agent(&user)
+ }
} else if allowed.contains(git2::USER_PASS_PLAINTEXT) {
git2::Cred::credential_helper(cfg, url, username)
} else if allowed.contains(git2::DEFAULT) {
let mut remote = try!(repo.remote_anonymous(&url, Some(refspec)));
try!(remote.add_fetch("refs/tags/*:refs/tags/*"));
remote.set_callbacks(&mut cb);
- try!(remote.fetch(&["refs/tags/*:refs/tags/*", refspec], None, None));
+ try!(remote.fetch(&["refs/tags/*:refs/tags/*", refspec], None));
Ok(())
})
}
use core::{Package, PackageId, Summary, SourceId, Source, Dependency, Registry};
use ops;
-use util::{self, CargoResult, internal, internal_error, human, ChainError, Config};
+use util::{CargoResult, internal, internal_error, human, ChainError, Config};
pub struct PathSource<'a, 'b: 'a> {
id: SourceId,
None => return Err(internal_error("Can't list files on a bare repository.", "")),
};
- // Right now there is a bug such that "/a/b".relative_from("/a/")
- // returns `None` so here we chop of the trailing slash if there is one.
- // It is unclear to me whether this is actually a bug with paths or not.
- let root = util::lose_the_slash(&root);
let pkg_path = pkg.root();
let mut ret = Vec::new();
let oid = try!(repo.refname_to_id(reference));
trace!("[{}] updating to rev {}", self.source_id, oid);
let object = try!(repo.find_object(oid, None));
- try!(repo.reset(&object, git2::ResetType::Hard, None, None, None));
+ try!(repo.reset(&object, git2::ResetType::Hard, None));
self.updated = true;
self.cache.clear();
Ok(())
use std::ffi;
use std::fmt;
use std::io;
-use std::old_io::IoError;
use std::process::{Output, ExitStatus};
use std::str;
from_error! {
semver::ReqParseError,
- IoError,
io::Error,
ProcessError,
git2::Error,
}
impl CargoError for semver::ReqParseError {}
-impl CargoError for IoError {}
impl CargoError for io::Error {}
impl CargoError for git2::Error {}
impl CargoError for json::DecoderError {}
pub use self::errors::{process_error, internal_error, internal, human};
pub use self::errors::{Human, caused_human};
pub use self::paths::{join_paths, path2bytes, bytes2path, dylib_path};
-pub use self::paths::{normalize_path, lose_the_slash};
+pub use self::paths::normalize_path;
pub use self::lev_distance::{lev_distance};
pub use self::hex::{to_hex, short_hash};
pub use self::dependency_queue::{DependencyQueue, Fresh, Dirty, Freshness};
}
pub fn normalize_path(path: &Path) -> PathBuf {
- let mut components = path.components();
- let mut ret = if let Some(c @ Component::Prefix { .. }) = components.peek() {
+ let mut components = path.components().peekable();
+ let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek()
+ .cloned() {
components.next();
PathBuf::new(c.as_os_str())
} else {
for component in components {
match component {
- Component::Prefix { .. } => unreachable!(),
- Component::Empty => { ret.push(""); }
+ Component::Prefix(..) => unreachable!(),
Component::RootDir => { ret.push(component.as_os_str()); }
Component::CurDir => {}
Component::ParentDir => { ret.pop(); }
return ret;
}
-/// Chop off the trailing slash of a path
-pub fn lose_the_slash(path: &Path) -> &Path {
- let mut components = path.components();
- match components.next_back() {
- Some(Component::CurDir) => components.as_path(),
- _ => path,
- }
-}
-
#[cfg(unix)]
pub fn path2bytes(path: &Path) -> CargoResult<&[u8]> {
use std::os::unix::prelude::*;
mod imp {
extern crate winapi;
extern crate "advapi32-sys" as advapi32;
- use std::os;
+ use std::io;
use std::ptr;
use self::winapi::{DWORD, HCRYPTPROV, HCRYPTHASH};
macro_rules! call{ ($e:expr) => ({
if $e == 0 {
- panic!("failed {}: {}", stringify!($e), os::last_os_error())
+ panic!("failed {}: {}", stringify!($e), io::Error::last_os_error())
}
}) }
use std::default::Default;
use std::fmt;
use std::fs;
-use std::io::prelude::*;
use std::path::{Path, PathBuf};
use std::slice;
use std::str;
-#![feature(io, path)]
-
extern crate curl;
extern crate "rustc-serialize" as rustc_serialize;
assert_eq!(req, vec![
"GET /foo/bar/info/refs?service=git-upload-pack HTTP/1.1",
"Accept: */*",
- "User-Agent: git/1.0 (libgit2 0.21.0)",
+ "User-Agent: git/1.0 (libgit2 0.22.0)",
].into_iter().map(|s| s.to_string()).collect());
drop(s);
"GET /foo/bar/info/refs?service=git-upload-pack HTTP/1.1",
"Authorization: Basic Zm9vOmJhcg==",
"Accept: */*",
- "User-Agent: git/1.0 (libgit2 0.21.0)",
+ "User-Agent: git/1.0 (libgit2 0.22.0)",
].into_iter().map(|s| s.to_string()).collect());
});
-use std::old_path;
+use std::path::MAIN_SEPARATOR as SEP;
use support::{basic_bin_manifest, execs, project, ProjectBuilder};
use support::{COMPILING, RUNNING};
use hamcrest::{assert_that};
-L dependency={dir}{sep}target{sep}debug \
-L dependency={dir}{sep}target{sep}debug{sep}deps`
",
- running = RUNNING, compiling = COMPILING, sep = old_path::SEP,
+ running = RUNNING, compiling = COMPILING, sep = SEP,
dir = p.root().display(), url = p.url(),
name = "foo", version = "0.0.1")
}
assert_that(p.cargo_process("run"), execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
if cfg!(windows) {
- // HACKHACK: On windows unlinking immediately after running often fails, so sleep
- use std::old_io::timer::sleep;
+ // On windows unlinking immediately after running often fails, so sleep
use std::time::duration::Duration;
- sleep(Duration::milliseconds(100));
+ ::sleep(Duration::milliseconds(100));
}
fs::remove_file(&p.bin("foo")).unwrap();
assert_that(p.cargo("run"),
use std::fs::{self, File};
use std::io::prelude::*;
-use std::old_io::timer;
use std::path::Path;
use std::time::Duration;
use git2;
let subrepo = s.open().unwrap();
let mut origin = subrepo.find_remote("origin").unwrap();
origin.add_fetch("refs/heads/*:refs/heads/*").unwrap();
- origin.fetch(&[], None, None).unwrap();
+ origin.fetch(&[], None).unwrap();
origin.save().unwrap();
subrepo.checkout_head(None).unwrap();
s.add_finalize().unwrap();
let repo = git2::Repository::open(&git_project.root()).unwrap();
let head = repo.head().unwrap().target().unwrap();
let head = repo.find_commit(head).unwrap();
- repo.branch("branchy", &head, true, None, None).unwrap();
+ repo.branch("branchy", &head, true).unwrap();
let project = project
.file("Cargo.toml", &format!(r#"
add(&repo);
commit(&repo);
- timer::sleep(Duration::milliseconds(1000));
+ ::sleep(Duration::milliseconds(1000));
// By default, not transitive updates
println!("dep1 update");
add(&repo);
commit(&repo);
- timer::sleep(Duration::milliseconds(1000));
+ ::sleep(Duration::milliseconds(1000));
let rev = repo.revparse_single("HEAD").unwrap().id();
let mut origin = subrepo.find_remote("origin").unwrap();
origin.set_url(git_project3.url().to_string().as_slice()).unwrap();
origin.add_fetch("refs/heads/*:refs/heads/*").unwrap();;
- origin.fetch(&[], None, None).unwrap();
+ origin.fetch(&[], None).unwrap();
origin.save().unwrap();
let id = subrepo.refname_to_id("refs/remotes/origin/master").unwrap();
let obj = subrepo.find_object(id, None).unwrap();
- subrepo.reset(&obj, git2::ResetType::Hard, None, None, None).unwrap();
+ subrepo.reset(&obj, git2::ResetType::Hard, None).unwrap();
}
sub.add_to_index(true).unwrap();
add(&repo);
commit(&repo);
- timer::sleep(Duration::milliseconds(1000));
+ ::sleep(Duration::milliseconds(1000));
// Update the dependency and carry on!
println!("update");
assert_that(project.cargo("update").arg("-v"),
}).unwrap();
foo.root().move_into_the_past().unwrap();
- timer::sleep(Duration::milliseconds(1000));
+ ::sleep(Duration::milliseconds(1000));
assert_that(foo.cargo("build"),
execs().with_status(0)
use std::fs::{self, File};
use std::io::prelude::*;
-use std::old_io::timer;
use std::time::Duration;
use support::{project, execs, main_file};
//
// We base recompilation off mtime, so sleep for at least a second to ensure
// that this write will change the mtime.
- timer::sleep(Duration::seconds(1));
+ ::sleep(Duration::seconds(1));
File::create(&p.root().join("baz/src/baz.rs")).unwrap().write_all(br#"
pub fn baz() { println!("hello!"); }
"#).unwrap();
COMPILING, p.url())));
// Make sure an update to bar doesn't trigger baz
- timer::sleep(Duration::seconds(1));
+ ::sleep(Duration::seconds(1));
File::create(&p.root().join("bar/src/bar.rs")).unwrap().write_all(br#"
extern crate baz;
pub fn bar() { println!("hello!"); baz::baz(); }
use std::env;
-use std::old_path;
+use std::path::MAIN_SEPARATOR as SEP;
use support::{project, execs};
use support::{COMPILING, RUNNING};
-L dependency={dir}{sep}target{sep}debug \
-L dependency={dir}{sep}target{sep}debug{sep}deps`
",
-running = RUNNING, compiling = COMPILING, sep = old_path::SEP,
+running = RUNNING, compiling = COMPILING, sep = SEP,
dir = p.root().display(),
url = p.url(),
)));
compiling = COMPILING,
dir = p.root().display(),
url = p.url(),
- sep = old_path::SEP,
+ sep = SEP,
prefix = env::consts::DLL_PREFIX,
suffix = env::consts::DLL_SUFFIX).as_slice()));
});
-use std::old_path;
+use std::path::MAIN_SEPARATOR as SEP;
use support::{project, execs, path2url};
use support::{COMPILING, RUNNING};
compiling = COMPILING,
running = RUNNING,
dir = path2url(p.root()),
- sep = old_path::SEP).as_slice()));
+ sep = SEP).as_slice()));
assert_that(&p.bin("foo"), existing_file());
});
compiling = COMPILING,
running = RUNNING,
dir = path2url(p.root()),
- sep = old_path::SEP).as_slice()));
+ sep = SEP).as_slice()));
assert_that(p.cargo("run").arg("--bin").arg("b"),
execs().with_status(0).with_stdout(format!("\
hello b.rs
",
running = RUNNING,
- sep = old_path::SEP).as_slice()));
+ sep = SEP).as_slice()));
});
test!(run_example {
compiling = COMPILING,
running = RUNNING,
dir = path2url(p.root()),
- sep = old_path::SEP).as_slice()));
+ sep = SEP).as_slice()));
});
test!(either_name_or_example {
compiling = COMPILING,
running = RUNNING,
dir = path2url(p.root()),
- sep = old_path::SEP).as_slice()));
+ sep = SEP).as_slice()));
});
test!(example_with_release_flag {
running = RUNNING,
dir = p.root().display(),
url = path2url(p.root()),
- sep = old_path::SEP).as_slice()));
+ sep = SEP).as_slice()));
assert_that(p.cargo("run").arg("-v").arg("--example").arg("a"),
execs().with_status(0).with_stdout(format!("\
running = RUNNING,
dir = p.root().display(),
url = path2url(p.root()),
- sep = old_path::SEP).as_slice()));
+ sep = SEP).as_slice()));
});
test!(run_dylib_dep {
compiling = COMPILING,
running = RUNNING,
dir = path2url(p.root()),
- sep = old_path::SEP).as_slice()));
+ sep = SEP).as_slice()));
assert_that(&p.release_bin("foo"), existing_file());
});
-use std::old_io::{MemWriter, IoResult, ChanReader, ChanWriter};
-use std::sync::mpsc::channel;
+use std::io::prelude::*;
+use std::io;
+use std::sync::{Arc, Mutex};
use term::{Terminal, TerminfoTerminal, color};
use hamcrest::{assert_that};
fn setup() {
}
-fn pair() -> (ChanWriter, ChanReader) {
- let (tx, rx) = channel();
- (ChanWriter::new(tx), ChanReader::new(rx))
+struct Sink(Arc<Mutex<Vec<u8>>>);
+
+impl Write for Sink {
+ fn write(&mut self, data: &[u8]) -> io::Result<usize> {
+ Write::write(&mut *self.0.lock().unwrap(), data)
+ }
+ fn flush(&mut self) -> io::Result<()> { Ok(()) }
}
test!(non_tty {
let config = ShellConfig { color: true, verbose: true, tty: false };
- let (tx, mut rx) = pair();
+ let a = Arc::new(Mutex::new(Vec::new()));
- Shell::create(Box::new(tx), config).tap(|shell| {
+ Shell::create(Box::new(Sink(a.clone())), config).tap(|shell| {
shell.say("Hey Alex", color::RED).unwrap();
});
- let buf = rx.read_to_end().unwrap();
- assert_that(buf.as_slice(), shell_writes("Hey Alex\n"));
+ let buf = a.lock().unwrap().clone();
+ assert_that(&buf[..], shell_writes("Hey Alex\n"));
});
test!(color_explicitly_disabled {
let config = ShellConfig { color: false, verbose: true, tty: true };
- let (tx, mut rx) = pair();
+ let a = Arc::new(Mutex::new(Vec::new()));
- Shell::create(Box::new(tx), config).tap(|shell| {
+ Shell::create(Box::new(Sink(a.clone())), config).tap(|shell| {
shell.say("Hey Alex", color::RED).unwrap();
});
- let buf = rx.read_to_end().unwrap();
- assert_that(buf.as_slice(), shell_writes("Hey Alex\n"));
+ let buf = a.lock().unwrap().clone();
+ assert_that(&buf[..], shell_writes("Hey Alex\n"));
});
test!(colored_shell {
- let term = TerminfoTerminal::new(MemWriter::new());
+ let term = TerminfoTerminal::new(Vec::new());
if term.is_none() { return }
let config = ShellConfig { color: true, verbose: true, tty: true };
- let (tx, mut rx) = pair();
+ let a = Arc::new(Mutex::new(Vec::new()));
- Shell::create(Box::new(tx), config).tap(|shell| {
+ Shell::create(Box::new(Sink(a.clone())), config).tap(|shell| {
shell.say("Hey Alex", color::RED).unwrap();
});
- let buf = rx.read_to_end().unwrap();
- assert_that(buf.as_slice(),
+ let buf = a.lock().unwrap().clone();
+ assert_that(&buf[..],
shell_writes(colored_output("Hey Alex\n",
color::RED).unwrap()));
});
-fn colored_output<S: Str>(string: S, color: color::Color) -> IoResult<String> {
- let mut term = TerminfoTerminal::new(MemWriter::new()).unwrap();
+fn colored_output(string: &str, color: color::Color) -> io::Result<String> {
+ let mut term = TerminfoTerminal::new(Vec::new()).unwrap();
try!(term.reset());
try!(term.fg(color));
- try!(term.write_str(string.as_slice()));
+ try!(write!(&mut term, "{}", string));
try!(term.reset());
try!(term.flush());
- Ok(String::from_utf8_lossy(term.get_ref().get_ref()).to_string())
+ Ok(String::from_utf8_lossy(term.get_ref()).to_string())
}
-#![feature(core, io, old_io, old_path)]
-#![feature(std_misc, io, path, fs, net, path_ext, fs_time, fs_walk)]
+#![feature(core, io, old_io)]
+#![feature(std_misc, io, fs, net, path_ext, fs_time, fs_walk)]
extern crate "rustc-serialize" as serialize;
extern crate cargo;
mod test_cargo_test;
mod test_cargo_version;
mod test_shell;
+
+#[allow(deprecated)]
+fn sleep(dur: std::time::Duration) {
+ std::old_io::timer::sleep(dur)
+}